
import 'package:get/get.dart';
import 'package:tot_android_flutter/eneity/user_entity.dart';
import 'package:tot_android_flutter/utils/JsonUtil.dart';
import 'package:tot_android_flutter/utils/sp/preference_utils.dart';

class Sp {
  static const String _KEY_USER_INFO = "user_info";

  static putUserInfo(UserEntity userInfo) {
    PreferenceUtils.instance.putString(_KEY_USER_INFO, JsonUtils.toJson(userInfo));
  }

  static UserEntity? getUserInfo() {
    String userInfoJson = PreferenceUtils.instance.getString(_KEY_USER_INFO);
    if(userInfoJson.isEmpty){
      return null;
    }
    return JsonUtils.fromJson(userInfoJson,UserEntity.fromJson);
  }
}